package com.atguigu.study.controller;

import com.atguigu.study.entities.User;
import com.atguigu.study.resp.ResultData;
import com.atguigu.study.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @auther zzyy
 * @create 2024-12-16 22:03
 */
@RestController
public class UserController
{
    @Resource
    private UserService userService;

    @PostMapping(value = "/user/add")
    public ResultData<Boolean> addUser(@RequestBody User user)
    {
        return ResultData.success(userService.addUser(user));
    }

    //http://localhost:1219/user/226
    @GetMapping(value = "/user/{id}")
    public ResultData<User> getUserById(@PathVariable("id") Integer id)
    {
        return ResultData.success(userService.getUserById(id));
    }
}
